package org.lightrpc.client;

import java.lang.reflect.Proxy;

/**
 * This class is responsible of creating
 * a objects for remote interfaces.
 * @author miku
 *
 */
public class ServiceFactory {
	/**
	 * This method returns the valid access point objects
	 * for remote calls.
	 * @param iface - interfaces of the remote objects
	 * @param Url - the url of the remote service
	 * @param port - port of the service
	 * @param path - root path, can be null (eg. /services/, not the name of the service or the service function)
	 * @return
	 */
	public static Object getRemoteObject(Class<?> iface, String url, int port, String path){
		//TODO:add possible validation method to this class
		RemoteFacade facade = new RemoteFacade(url, port, path);
		return Proxy.newProxyInstance(ServiceFactory.class.getClassLoader(),
				new Class[]{iface}, facade);
	}
}
